import time
from wordpress_project.base.page_operation import PageTools


class register(PageTools):
    register_url = 'http://192.168.0.125:9009/wp-login.php?action=register'
    username_ele = '[name="user_login"]'
    email_ele = '[name="user_email"]'
    button_ele = '[id="wp-submit"]'
    register_success_ele = '[class="message"]'
    register_fail_ele = '[id="login_error"]'

    def register_action(self, username, email):
        self.visit(self.register_url)
        time.sleep(1)
        self.by_css(self.username_ele).send_keys(username)
        time.sleep(1)
        self.by_css(self.email_ele).send_keys(email)
        time.sleep(1)
        self.by_css(self.button_ele).click()
        time.sleep(3)

    def get_success_msg(self):
        return self.by_css(self.register_success_ele).text

    def get_fail_msg(self):
        return self.by_css(self.register_fail_ele).text
